package yf.mall.entity;


import com.fasterxml.jackson.annotation.JsonProperty;
import com.yf.utils.GenUtils;
import lombok.Setter;
import lombok.Getter;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;


/**
 * 用户实体
 * 表名 user
 *
 *
 *
 * @date Tue Sep 17 15:12:41 CST 2019
 */
@Setter
@Getter
public class UserEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    //
    private Long id;
    //微信Openid
    private String openId;
    //小程序Openid
    private String miniOpenId;
    //微信统一ID
    private String unionId;
    //微信头像
    private String avatar;
    //手机号码
    private String mobile;
    //密码
    private String password;
    //名称
    private String name;
    //编码
    private String code;
    //团队编码
    @JsonProperty("tCode")
    private String tCode;
    //联姻ID
    private Long rid;
    private String rInfo;
    //服务商ID
    private Long fid;
    private String fInfo;
    //上级ID
    private Long pid;
    private String pInfo;
    //团队树
    private String team;
    //级别名称
    private Long levelId;
    //加入时间
    private Date time;

    //升级时间
    private Date lvTime;

    //备注
    private String remark;
    //起止时间
    Date[] times;
    //ENUM-状态:"ACTIVE-正常","BAN-禁用"
    private Integer status;

    //抖音账号
    private String dyNumber;

    private Integer vip;

    private BigDecimal percent;

    //钻石VIP
    private Integer zsVip;

    //手动级别
    private Integer manLv;

    //临时计数存储
    private BigDecimal temProfit = BigDecimal.ZERO;

    private String teamCode;

    private Integer teamLv;

    //临时存储
    private String levelName;

    //临时直推
    private Integer childCount;

    //临时团队
    private Integer teamCount;

    public void addTemProfit(BigDecimal decimal) {
        this.temProfit = this.temProfit.add(decimal);
    }

    public UserEntity() {

    }

    public String getTCode() {
        if (this.teamCode != null) {
            return this.teamCode;
        }
        return this.tCode;
    }

//    public String getTeamCode() {
//        if(this.code==null)return null;
//        return CodeUtil.getTeam(this.code);
//    }


    public UserEntity(String mobile, String openId, String unionId, String avatar, String name, String code, String tCode, Long pid, String team, Long levelId, Date time, Integer status) {
        this.mobile = mobile;
        this.openId = openId;
        this.unionId = unionId;
        this.avatar = avatar;
        this.name = name;
        this.code = code;
        this.tCode = tCode;
        this.teamCode = tCode;
//        this.rid = rid;
        this.pid = pid;
        this.team = team;
        this.levelId = levelId;
        this.time = time;
        this.status = status;
    }

    public static void main(String[] args) {
//        String jdbcUrl = "jdbc:mysql://localhost:3306/zbmall?serverTimezone=CTT";
        String jdbcUrl = "jdbc:mysql://localhost:3306/dx?serverTimezone=CTT";
        String userName = "root";
//        String password = "root";
        String password = "12345678";
        String packageName = "yf.mall";
        String filePath = "/Users/hxf/Desktop/autoCode.zip";
        //      String filePath = "e:/autoCode.zip";


        try {
            GenUtils.init(jdbcUrl, userName, password, filePath, packageName).generatorCode("app_material");
//            GenUtils.init(jdbcUrl, userName, password, filePath,packageName).generatorCode("mall_config");
//            GenUtils.init(jdbcUrl, userName, password, filePath,packageName).table("mall_card").alias("mallCard").join("user").alias("user").on("mallCard.user_id","user.id").generateVoCode();
//           生成账户记录
//           GenUtils.init(jdbcUrl,userName,password,filePath,packageName).table("shop").alias("shop").join("user").alias("user").on("shop.code","user.code").generateVoCode();
            //生成用户
//            GenUtils.init(jdbcUrl, userName, password, filePath,packageName).table("user").alias("user").join("user").alias("referer").on("user.rid", "referer.id").join("user").alias("topUser").on("user.pid", "topUser.id").join("level").alias("level").on("level.id", "user.level_id").generateVoCode();
//生成订单
//            GenUtils.init(jdbcUrl,userName,password,filePath,packageName).table("mall_order").alias("mallOrder").join("user").alias("user").on("mallOrder.user_id","user.id").join("user").alias("fromUser").on("mallOrder.from_user_id","fromUser.id").generateVoCode();
            //生成价格
//            GenUtils.init(jdbcUrl, userName, password, filePath,packageName).table("price" ).alias("price" ).join("level" ).alias("level" ).on("price.level_id", "level.id" ).generateVoCode();
//            GenUtils.init(jdbcUrl, userName, password, filePath,packageName).table("account" ).alias("account" ).join("user" ).alias("user" ).on("record.from_user_id", "user.id" ).join("user").alias("toUser").on("record.to_user_id","fromUser.id").generateVoCode();
//            GenUtils.init(jdbcUrl, userName, password, filePath,packageName).table("sign" ).alias("sign" ).join("course" ).alias("course" ).on("sign.course_id", "course.id" ).generateVoCode();
//            GenUtils.init(jdbcUrl, userName, password, filePath,packageName).table("mall_act" ).alias("act" ).join("mall_goods" ).alias("goods" ).on("act.goods", "course.id" ).generateVoCode();
//              GenUtils.init(jdbcUrl, userName, password, filePath,packageName).table("coupon" ).alias("coupon" ).join("user" ).alias("user" ).on("user.id", "user_id" ).generateVoCode();

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
